/**
 * @description 路由拦截状态管理，目前两种模式：all模式与intelligence模式，其中partialRoutes是菜单暂未使用
 */
import { defineStore } from 'pinia'
import type { netConfigState, testHeaderState } from '@/types/app'

export const netConfigUse = defineStore('net', {
  state: (): netConfigState => ({
    config: {
      testHeader: [
        {
          key: 'Authorization',
          val: 'xxx'
        }
      ],
      baseUrl: 'http://127.0.0.1:8880',
      // baseUrl: 'http://124.222.34.122',
      tokenName: 'Authorization',
      headers: {},
      list: 'data',
      total: 'total',
      pageSize: 'pageSize',
      pageNo: 'pageNo',
      apis: {
        login: {
          api: '/admin/login/login',
          method: 'post'
        },
        userInfo: {
          api: '/admin/User/info',
          method: 'post'
        },
        updInfo: {
          api: '/member/updateInfo',
          method: 'post'
        },
        updPass: {
          api: '/member/updatePass',
          method: 'post'
        },
        routerAll: {
          api: '/admin/Route/list',
          method: 'post'
        },
        roleAll: {
          api: '/admin/Role/allList',
          method: 'post'
        },
        //  获取布局
        getLayout: {
          api: '/admin/Route/detail',
          method: 'post'
        },
        //  修改布局
        setLayout: {
          api: '/admin/Route/edit',
          method: 'post'
        },
        //  获取事件表单布局
        getLayoutEvent: {
          api: '/admin/Spread/detail',
          method: 'post'
        },
        eventGetList: {
          api: '/admin/Spread/list',
          method: 'post'
        },
        eventDel: {
          api: '/admin/Spread/dels',
          method: 'post'
        },
        eventAdd: {
          api: '/admin/Spread/add',
          method: 'post'
        },
        eventEdit: {
          api: '/admin/Spread/edit',
          method: 'post'
        },
        eventBtnGetList: {
          api: '/admin/SpreadBtn/list',
          method: 'post'
        },
        evenBtntDel: {
          api: '/admin/SpreadBtn/dels',
          method: 'post'
        },
        eventBtnAdd: {
          api: '/admin/SpreadBtn/add',
          method: 'post'
        },
        eventBtnEdit: {
          api: '/admin/SpreadBtn/edit',
          method: 'post'
        }
      }
    }
  }),
  getters: {
    getNetConfig: state => state.config
  },
  actions: {
    setHeader(header: testHeaderState[]) {
      this.config.testHeader = header
    }
  }
})
